package flc.ast.adapter;

import android.graphics.Color;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class RecommendAdapter extends StkProviderMultiAdapter<StkResBean> {

    public RecommendAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new HotProvider());
    }

    private int type=0;

    public void setType(int type) {
        this.type = type;
    }

    private class HotProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_recommend;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(getContext()).load(bean.getThumbUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivRecommendItemImg));
            baseViewHolder.setText(R.id.tvRecommendItemName,bean.getName());
            if (type==0){
                baseViewHolder.setTextColor(R.id.tvRecommendItemName, Color.parseColor("#241F32"));
            }else if (type==1){
                baseViewHolder.setTextColor(R.id.tvRecommendItemName, Color.parseColor("#FFFFFF"));
            }
            if (bean.getTagNameList()!=null||bean.getTagNameList().size()!=0){
                String tag="";
                for (String s : bean.getTagNameList()) {
                    tag+=s+" ";
                }
                baseViewHolder.setText(R.id.tvRecommendItemTag,tag);
            }
        }
    }

}
